﻿#ifndef CHANGEIP_H
#define CHANGEIP_H

#include <QMainWindow>
#include <QCloseEvent>
#include <QDialog>
#include <QMessageBox>
#include <QClipboard>
#include <QShortcut>
//#include "DataStruct.h"
//#include "CSqliteOperator.h"
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>
#include <QComboBox>

#include <QtNetwork/QNetworkInterface>
#include <QtCore/QCoreApplication>
namespace Ui {
class ChangeIp;
}

class ChangeIp : public QMainWindow
{
    Q_OBJECT

public:
    explicit ChangeIp(QWidget *parent = nullptr);
    ~ChangeIp();

    //void setStaticIP(const QString &interfaceName, const QString &ipAddress, const QString &netmask, const QString &gateway, const QString &dns1, const QString &dns2);

private slots:
    void on_pushButton_clicked();
    void on_pushButton_search_clicked();
    void onIpMacIndexChanged(int index);
    //void onComboBoxIndexChanged(int index);
   // void ChangeIp::choosename(const QString& strMName);
    
    void on_pushButton_DHCP_clicked();

private:
    Ui::ChangeIp *ui;
    QSqlDatabase db;
   // void setStaticIP(const QString& interfaceName, const QString& ipAddress, const QString& netmask, const QString& gateway, const QString& dns1, const QString& dns2);
    void setManualIP(const QString& adapterName, const QString& ip, const QString& subnet, const QString& gateway, const QString& dns1, const QString& dns2);

    void setStaticIP(const QString& interfaceName, const QString& ipAddress, const QString& netmask, const QString& gateway, const QString& dns1, const QString& dns2);
    QString getInterfaceByMacAddress(const QString& macAddress);
    void loadSettings();
    void saveSettings();
    //CSqliteOperator P2DModelOperatorr;
    ////vector<string> allP2DModelParamName;
    void queryDatabase(const QString& dbPath,  QString& dbname, QString& index);

    void setDhcp(const QString& interfaceName);


protected:
    // 重载 closeEvent 方法
    void closeEvent(QCloseEvent* event) override {
        saveSettings();
        event->accept();  // 接受关闭事件
    }
};

#endif // CHANGEIP_H
